package com.zhonghui.mes.service.impl;

import com.zhonghui.common.utils.SecurityUtils;
import com.zhonghui.mes.domain.MesProductionSampling;
import com.zhonghui.mes.domain.vo.MesProductionSamplingVo;
import com.zhonghui.mes.mapper.MesProductionSamplingMapper;
import com.zhonghui.mes.service.IMesProductionSamplingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * 生产采样 Service业务层处理
 * 
 * @author yy
 * @date 2022-05-25
 */
@Service
public class MesProductionSamplingServiceImpl implements IMesProductionSamplingService 
{
    @Autowired
    private MesProductionSamplingMapper mesProductionSamplingMapper;

    /**
     * 查询生产采样
     * 
     * @param id 生产采样主键
     * @return 生产采样
     */
    @Override
    public MesProductionSamplingVo selectMesProductionSamplingById(Long id)
    {
        return mesProductionSamplingMapper.selectMesProductionSamplingById(id);
    }

    /**
     * 查询生产采样列表
     * 
     * @param mesProductionSamplingVo 生产采样
     * @return 生产采样
     */
    @Override
    public List<MesProductionSamplingVo> selectMesProductionSamplingList(MesProductionSamplingVo mesProductionSamplingVo)
    {
        return mesProductionSamplingMapper.selectMesProductionSamplingList(mesProductionSamplingVo);
    }

    /**
     * 新增生产采样
     * 
     * @param mesProductionSampling 生产采样
     * @return 结果
     */
    @Override
    public int insertMesProductionSampling(MesProductionSampling mesProductionSampling)
    {
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        mesProductionSampling.setSerialNumber("SCCY" + format.format(date));
        mesProductionSampling.setCheckUserId(SecurityUtils.getUserId());
        mesProductionSampling.setInspectorTime(new Date());
        return mesProductionSamplingMapper.insertMesProductionSampling(mesProductionSampling);
    }

    /**
     * 修改生产采样
     * 
     * @param mesProductionSampling 生产采样
     * @return 结果
     */
    @Override
    public int updateMesProductionSampling(MesProductionSampling mesProductionSampling)
    {
        return mesProductionSamplingMapper.updateMesProductionSampling(mesProductionSampling);
    }

    /**
     * 批量删除生产采样
     * 
     * @param ids 需要删除的生产采样主键
     * @return 结果
     */
    @Override
    public int deleteMesProductionSamplingByIds(Long[] ids)
    {
        return mesProductionSamplingMapper.deleteMesProductionSamplingByIds(ids);
    }

    /**
     * 删除生产采样信息
     * 
     * @param id 生产采样主键
     * @return 结果
     */
    @Override
    public int deleteMesProductionSamplingById(Long id)
    {
        return mesProductionSamplingMapper.deleteMesProductionSamplingById(id);
    }
}
